<template>
  <div>
    <el-form ref="elForm" :model="formData" :rules="rules" size="medium" label-width="100px">
      <el-form-item label="请假原因" prop="reason">
        <el-input v-model="formData.reason" type="textarea" placeholder="请输入请假原因"
                  :autosize="{minRows: 4, maxRows: 4}" :style="{width: '100%'}"></el-input>
      </el-form-item>
      <el-form-item label="请假时间" prop="days">
        <el-input-number v-model="formData.days" placeholder="请假时间"></el-input-number>
      </el-form-item>
      <el-form-item size="large">
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
import { processStart } from "@/api/base/baseProcess";
export default {
  components: {},
  props:{
    processId:{
      type:Number,
      default:null
    }
  },
  data() {
    return {
      formData: {
        reason: undefined,
        days: undefined,
      },
      rules: {
        reason: [{
          required: true,
          message: '请输入请假原因',
          trigger: 'blur'
        }],
        days: [{
          required: true,
          message: '请假时间',
          trigger: 'blur'
        }],
      },
    }
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    submitForm() {
      this.$refs['elForm'].validate(valid => {
        if (!valid) return
        // TODO 提交表单
        processStart(this.processId,this.formData).then(res=>{
          this.$modal.msgSuccess("请求成功");
          this.$emit("colseDialog");
        })
      })
    },
    resetForm() {
      this.$refs['elForm'].resetFields()
    },
  }
}

</script>
<style>
</style>
